<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>材料需求申请</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../resources/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../resources/css/style.css">
    <style>
        .details ul li {width: 50%;float: left;}
        .layui-table thead th{text-align: left;}
        .layui-table td{text-indent: 1rem; font-size: 12px; color: #333;}
        .detailed{background-color: #FFF; font-size: 12px; color: #333333; line-height: 24px;margin-top: 8px;}
        /*.details ul,li{list-style: inherit;}*/
        .detailed p:after {
            content: "\0020";
            display: block;
            height: 0;
            clear: both;
        }
        .detailed p:before {content: "● "; color: #e3e3e3; font-size: 12px; margin-right: 5px; float: left;}
        .detailed .detaL{width: 120px;display: inline-block; float: left;    padding-right: 20px;}
        .detailed .dataR{display: inline-block;float: left;}
        .detailed p{margin-bottom: 10px;}

        .detailedfoot ul {display: flex;justify-content: space-around;}
        .layui-table thead th{text-align: left;}

        .layui-table td{text-indent: 1rem; font-size: 12px; color: #333;}
        table tbody tr td{text-align: left;}
        .maskmain table td, th{text-align: left;}
        .detailedfoot{padding: 15px 35px;height:50%;overflow: auto;}
        .engineering{width: 49%;display: inline-block;float: left; padding: 0 10px;margin-left: -10px;height: 400px;margin-bottom: 20px;}
        .details{height: 20%;}
        .titles{height: 10%;}
        .detailwarp{padding-left:22px;}
        @media screen and (max-width: 750px){
            .MOVE_list {height: 180px;padding: 16px 0;background-color: #F7F7F7;}
            #LAY_demo1 li{border-bottom: 3px solid #DBE7FF;}
            .MOVE_detailsBOT{border-top: 2px solid #EBEBEB;}
            #LAY_demo1 li{padding: 10px;}
            .layui-form-pane .layui-form-label{border: 0;!important;background-color: #F7F7F7;}
            .MOVE_title{top: 0;}
            ._MOVE .houtui{position: relative;margin-left: 50px;}
            .MOVE_main{margin-top: 45px;}

        }
        .Tian .shan{display: none;}
        .zeng{display: none;}
        .Tian .zeng{display: block;}
        .tijiao{position: absolute;top: 8px;right: 15px; background-color: transparent; font-size: 20px;}
        .bixuan{left: 2px; top: 11px;}
    </style>
</head>
<body>
<form class="layui-form layui-form-pane" action="" >

    <div class="_MOVE">

        <div class="MOVE_title">
            <div class="site-tree-mobile layui-show houtui" onclick="history.back(-1);">
                <i class="layui-icon">&#xe603;</i>
            </div>
            <span class="zhanwei"></span>
            <p class="MOVE_biaoti">材料需求申请</p>
            <span class="shousuo"><button class="layui-btn layui-btn-sm tijiao" lay-submit lay-filter="_subm">确定
            </button>
</span>

        </div>
            <div class="MOVE_main">

                    <ul class="flow-default" id="LAY_demo1">
                        <li>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="bixuan">*</span>申请单单号:</label>
                                <div class="layui-input-block">
                                    <input type="text" name="feed_Code" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input cai">
                                    <input type="hidden" name="sup_Code" autocomplete="off" class="layui-input"
                                           value="我是个死值">

                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="bixuan">*</span>工程名称:</label>
                                <div class="layui-input-inline">
                                    <select name="cc_UUID" lay-verify="required" lay-search="">
                                        <option value="">直接选择或搜索选择</option>
                                    </select>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="bixuan">*</span>供货时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" name="supply_Time" lay-verify="required" id="test-limit3" placeholder="yyyy-MM-dd hh:mm:ss">
                                    <div class="icons">

                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="bixuan">*</span>收货地址:</label>
                                <div class="layui-input-block">
                                    <input type="text" name="f_adr" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input cai">
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="bixuan">*</span>申请人:</label>
                                <div class="layui-input-block">
                                    <input type="text" name="feed_sqr" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                                </div>
                            </div>
                        </li>
                        <li class="Tian caiwarp">
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="bixuan">*</span>材料名:</label>
                                <div class="layui-input-inline" style="display: flex;justify-content: space-between;">
                                    <select name="modules" lay-verify="required" lay-search="" class="modules cai">
                                        <option value="">请选择</option>
                                    </select>
                                    <button class="layui-btn tianjias" type="button" style="width: 40px;text-align: center;padding: 0;"><i class="layui-icon zeng">&#xe654;</i> <i class="layui-icon shan">&#xe640;</i> </button>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="bixuan">*</span>数量:</label>
                                <div class="layui-input-block">
                                    <input type="number" name="title" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input _nums">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">备注:</label>
                                <div class="layui-input-block">
                                    <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input beizhu">
                                </div>
                            </div>
                        </li>

                    </ul>

            </div>

    </div>


</form>

<script src="../../../resources/layui/layui.js" charset="utf-8"></script>
<script src="../../../resources/js/style.js"></script>
<script src="../../../resources/js/api.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate','flow'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;



        //前后若干天可选，这里设置不能选过去的日期      最远可选1000天之后
        panduanshijian('#test-limit3','#test-limit4',0,1000,'.layui-btn-normal');     //查询 开始结束时间判断
        //点击按钮  添加数据输入框
        $('.tianjias').on('click',function () {
           var xinzeng=$(this).parents('.Tian').html();
           $('.Tian').after('<li class="shanchu caiwarp">'+xinzeng+'</li>');
            form.render();
        });
        //监听删除  数据框
        $(document).on('click','.shanchu button',function () {
            $(this).parents('.shanchu').remove();
        })
        //加载企业下拉
        ajaxs('/api/ctteam/loadMatFeedList.do','post',{},function (data) {
            console.log(data)
            $('.site-tree-mobile').css('display','none!important')
            var datas=data.data;
            for (var i=0;i<datas.length;i++){
                $("[name='cc_UUID']").append(' <option value="'+datas[i].cc_UUID+'">'+datas[i].compid+'</option>')
            }

            form.render();
        })
        //加载材料下拉
        ajaxs('/api/public/loadPriDropDown.do','post',{'type':'b'},function (data) {
            console.log(data);
            var datas=data.data;
            for(var i=0;i<datas.length;i++){
                $('.modules').append('<option value="'+datas[i].mat_id+'">'+datas[i].mat_Name+'</option>');
            }
            form.render();
        })


        //监听提交
        form.on('submit(_subm)', function(data){
            console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
            console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
            console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            var sd='';
            data.field.p=getCookie('yanzheng');
            $('.caiwarp').each(function () {
                var cailiaoID=$(this).children('.layui-form-item').eq(0).children('.layui-input-inline').children('[name="modules"]').val();                    //获取材料id
                console.log(cailiaoID)
                var
                    NumBer=$(this).children('.layui-form-item').eq(1).children('.layui-input-block').children('._nums').val();
                var beizhu=$(this).children('.layui-form-item').eq(2).children('.layui-input-block').children('.beizhu').val();
                sd+=cailiaoID+','+NumBer+','+beizhu+'|';
                console.log(beizhu)
            })
            data.field.sd=sd;
            tiaoAlertAjax('/api/ctteam/addMatFeed.do',data.field,'.tijiao');
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });



    })
</script>
</body>
</html>